package game.views;

import game.modes.ModeManage;
import game.data.GameFightAnalysisLogData.MultiFightAnalysisData;
import game.data.FightAnalysisData;
import hx.display.UILoadScene;

/**
 * 角色结算日志界面
 */
@:build(hx.macro.UIBuilder.build("assets/views/RoleLogView.xml"))
class RoleLogView extends UILoadScene {
	private var _logs1:RolePKLogData;

	private var _logs2:RolePKLogData;

	public function new(logs1:RolePKLogData, logs2:RolePKLogData) {
		super();
		_logs1 = logs1;
		_logs2 = logs2;
	}

	override function onLoaded() {
		super.onLoaded();
		for (i in 0...3) {
			var item:RoleLogItem = cast this.getChildById("r" + (i + 1));
			item.setData(_logs1.data[i]);
		}
		for (i in 0...3) {
			var item:RoleLogItem = cast this.getChildById("e" + (i + 1));
			item.setData(_logs2.data[i]);
		}
		this.troop1.setData(_logs1.winState, _logs1.winTimes);
		this.troop2.setData(_logs2.winState, _logs2.winTimes);
		this.close.clickEvent = () -> {
			// 回到上一个模式中
			ModeManage.reset();
		}
	}
}

typedef RolePKLogData = {
	/**
	 * 玩家名称
	 */
	var ?playerName:String;

	/**
	 * 是否胜利
	 */
	var winState:WinState;

	/**
	 * 胜利次数
	 */
	var winTimes:Int;

	var data:Array<RoleLogData>;
}

enum abstract WinState(Int) to Int {
	var WIN = 1;
	var LOSE = 2;
	var DRAW = 3;
}

typedef RoleLogData = {
	/**
	 * 角色id
	 */
	var id:String;

	/**
	 * 战斗分析数据
	 */
	var data:MultiFightAnalysisData;
}
